package com.fduss.mazegame.core.unit;

import com.fduss.mazegame.util.Direction;

/**
 * // A mobile entity.
 */
public abstract class Mob extends Entity {

    private boolean alive;

    Mob(Place place) {
        super(place);
        alive = true;
    }

    public boolean move(Direction dir) {
        Place dst = place.placeAt(dir);
        if (dst == null) {
            return false;
        }
        if (!dst.isWalkable()) {
            return false;
        }
        this.place.rmEntity(this);
        dst.addEntity(this);
        this.place = dst;
        return true;
    }

    public boolean isAlive() {
        return alive;
    }

    public void setAlive(boolean alive) {
        this.alive = alive;
    }

}
